home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / msctools.arc / MSCTOOLS.DOC next >
Text File  |  1985-09-05  |  11KB  |  468 lines

  1.                                 MSC TOOLS LIBRARY 
  2.  
  3.  
  4. MSCTOOLS is a collection of rountines that I have been using on other compilers
  5. for quite some time and have ported over to the Microsoft C Compiler.  They are
  6. completely written in C and should port to other machines with little modifica-
  7. tion.  I could probably add more speed to them by rewriting them in assembler
  8. but somehow to me that defeats the purpose of the C language.  You should have
  9. received the following on the diskette.
  10.  
  11.               MSCTOOLS.LIB..................Link library
  12.               MSCTOOLS.DOC..................This Documentation
  13.        
  14. Possible you will have received a file called "README" which lists the known
  15. bugs and any other pertinent information.  I am constantly adding new func-
  16. tions to the library and this file will contain the current release and new
  17. functions added since the last release.
  18.  
  19. The source code is available for $25 from
  20.  
  21.                       PC-SYSTEMS
  22.                       PO BOX 471114
  23.                       TULSA, OK 74147-1114 
  24.  
  25. You will receive a diskette containing the latest version of the functions.  
  26. If you encounter problems you can write me at the above address or leave a
  27. comment on my BBS at:
  28.  
  29.                       918-749-0718
  30.  
  31. And now to the fucntions!
  32. Thanks, have fun and good luck!  Lynn Long
  33.  
  34.              
  35.  
  36. --------------------------------------------------------------------------
  37.  
  38. aputc(char,attr,page,number) 
  39.  
  40. This function puts a character one or more times to the specified page with
  41. the specified attribute.  If you are using text modes then the page must be
  42. specified.  It need not be given for graphics modes.  The following  would
  43. display upon a monochrome monitor twenty x's in reverse video and blinking,
  44. at the current cursor location.
  45.  
  46.     aputc('x',0x0f0,0,20);
  47.  
  48. Other valid display modes in text (not graphic) are:
  49.     Result        value    comment
  50.         -----------    ----    --------------
  51.     Non-Display    0x00     non-display as passwords on screen
  52.     Underline    0x01    underlines the characters displayed
  53.     Normal        0x07    Normal mode-white on black
  54.     Intense        0x08    Intensifies the characters
  55.     Reverse vidio    0x70    black on white
  56.     Blinking    0x80    blinking
  57.  
  58. The modes may be combined for added effects although common sense 
  59. should dictate that some should not be combined.
  60.  
  61.             0xf0    Reverse black on white blinking    
  62.             0x0f    White on Black, intense
  63.             0x70    Reverse black on white
  64.  
  65. Play around with the differnt modes and you will be surprised at some
  66. of the combinations that you can come up with.
  67.  
  68. -------------------------------------------------------------------------
  69.  
  70. cls()
  71.  
  72. This function clears the console and positions the cursor at row zero 
  73. and column zero.
  74.  
  75.     main()
  76.     {
  77.         cls();
  78.     }
  79.  
  80.  
  81.  
  82. -------------------------------------------------------------------------
  83.  
  84. curdrive()
  85.  
  86. This function returns the current default data drive.  It is called as
  87. follows.   Since it returns character it must be declared before you 
  88. call it which is always good practice in C. (I preach it but don't always
  89. practice it);
  90.  
  91.     main()
  92.     {    
  93.         char curdrive();
  94.         printf("Default drive is %c\n",curdrive);
  95.     }
  96.                 
  97.                 
  98. -------------------------------------------------------------------------
  99.  
  100. cursoff()
  101.  
  102. Sometimes the cursor can be annoying sitting there blinking on the screen.
  103. This function will turn it off and you can turn it back on again with
  104. curson().
  105.  
  106.     main()
  107.     {
  108.         cursoff();
  109.     }
  110.  
  111.  
  112. -------------------------------------------------------------------------
  113.  
  114. curson()
  115.  
  116. This function turns the cursor back on.  It resets it back to its initial
  117. boot up size for both color and monochrome.  This function calls "montyp"
  118. to determine how to reset the cursor.
  119.  
  120.  
  121.     main()
  122.     {
  123.         curson();
  124.     }
  125.  
  126.  
  127. -------------------------------------------------------------------------
  128.  
  129.  
  130. disk()
  131.  
  132. This function returns the number of logical disk drives attached to the
  133. system.  It is called as follows.
  134.  
  135.     main()
  136.     {
  137.         printf("Number of disk drives attached",disk());
  138.     }
  139.  
  140.  
  141.  
  142. -------------------------------------------------------------------------
  143.  
  144.  
  145. equip()
  146.  
  147. This function returns 16 bits which can then be tested to determint the
  148. equipment attached to the system.  It is called as follows.
  149.  
  150.     main()
  151.     {
  152.         int i=0;
  153.         i=equip();
  154.         j=i & 0xc000;
  155.         j >>=14;
  156.         printf("the number of printers attached is %d\n",j);
  157.     }           
  158.  
  159.  
  160. Other hardware attached can be dtermined as follows.
  161.  
  162.     communications ports
  163.               
  164.     j=i & 0x0e00;
  165.     j >> = 9;
  166.  
  167.     
  168.  
  169. -------------------------------------------------------------------------
  170.  
  171. frame(row,col,hgt,wth)
  172.  
  173.  
  174. This function draws a box on the screen at the specified row and col for
  175. the specified height and width.  It is called as follows.
  176.  
  177.     main()
  178.     {
  179.         frame(10,10,10,60);
  180.  
  181.     }
  182.  
  183.  
  184. This would put a box on the screen at row 10, column 10 for a hight of
  185. 10 rows and a width of 60 columns.
  186.  
  187.  
  188.  
  189. -------------------------------------------------------------------------
  190.  
  191.  
  192. getmode(mode,khar,page)
  193.  
  194. This function returns the current screen mode, the character width and the
  195. page number.  The arguments are pointers and thus must be passed to the
  196. function as address.  It can be called as follows.
  197.  
  198.  
  199.     main()
  200.     {        
  201.         int *mode, *khar, *page;
  202.  
  203.         getmode(mode, khar, page);
  204.         printf("The current mode is %d character width is %d and
  205.             page number is %d\n",*mode,*khar,*page);
  206.  
  207.     }
  208. or
  209.      
  210.  
  211.     main()
  212.     {
  213.         int mode,khar,page;
  214.         getmode(&mode,&khar,%page);
  215.         printf("mode is %d, char is %d and page is %d",
  216.             mode, khar, page);
  217.                                    
  218.     }
  219.  
  220.  
  221.  
  222. -------------------------------------------------------------------------
  223.  
  224. inchar(port)
  225.  
  226. This function returns a character from the specified communications port.
  227. The port first has to be initialized with the correct baud rate, parity,
  228. data bits, and stop bits with the function "setport" before it will work
  229. correctly.  It returns the character if it was returned ok else it returns
  230. the NULL character if an error condition resulted.  If an error was
  231. returned then you can use the "portstat" function to determine what happened.
  232. The function is called as follows.
  233.  
  234.     main()
  235.     {        
  236.         char buffer[128];
  237.         int i,stat;
  238.         if((buffer[i]=inchar(1)) != NULL)
  239.             break;
  240.         else      
  241.             stat=portstat(1);
  242.  
  243.     }
  244.  
  245.  
  246. -------------------------------------------------------------------------
  247.  
  248.  
  249. locate(row,col)
  250.  
  251. This function positions the cursor at the row and column specifed in the
  252. arguments.  It is like the locate function in BASIC and is called as
  253. follows.
  254.  
  255.  
  256.     main()
  257.     {
  258.         locate(12,12);
  259.     }
  260.  
  261.  
  262.  
  263. -------------------------------------------------------------------------
  264.  
  265. lppos(row,col,pixrow,pixcol)
  266.  
  267. I have never known anyone to use a lightpen on the IBM PC but I am sure
  268. there are those of you out there who do.  This is for you!  The arguments
  269. are pointers and thus have to be passed as addresses as follows.
  270.  
  271.  
  272.     main()
  273.     {
  274.  
  275.         int row, col, pixrow, pixcol;
  276.  
  277.         lppos(&row,&col,&pixrow,&pixcol);
  278.         printf("row = %d, col=%d pixel row =%d pixel col = %d ",
  279.             row,col,pixrow,pixcol);
  280.  
  281.  
  282. or
  283.         int *row, *col, *pixrow, *pixcol;
  284.  
  285.         lppos(row,col,pixrow,pixcol);
  286.  
  287.  
  288.     }
  289.  
  290. -------------------------------------------------------------------------
  291.      
  292.  
  293. portstat(port)
  294.  
  295. This function returns the status of a serial or communications port.  It
  296. returns a word of bits that can be tested to determine the existing con-
  297. ditions.  The high-order eight bits determine the line control status and
  298. the low-order eight bits determine the modem status.It is called and tested
  299. as follows.
  300.  
  301.  
  302.     main()
  303.     {
  304.  
  305.         int stat;
  306.         stat=portstat(1);
  307.         if(stat & 0x8000)
  308.             puts("Time out occurred");
  309.         if(stat & 0x4000)
  310.             puts("trans shift register empty");
  311.         if(stat & 0x2000)
  312.             puts("trans hold reg empty");
  313.         if(stat & 0x1000)
  314.             puts("Break detected");
  315.         if(stat & 0x0800)
  316.             puts("Framing error");
  317.         if(stat & 0x0400)
  318.             puts("parity error");
  319.         if(stat & 0x0200)
  320.             puts("overrun error);
  321.         if(stat & 0x0100)
  322.             puts("data ready");
  323.  
  324. the modem status signals are detected as follows.        
  325.         
  326.         if(stat & 0x0080)
  327.             puts("line signal detect");
  328.         if(stat & 0x0040)
  329.             puts("ring indicator on");
  330.         if(stat & 0x0020)
  331.             puts("data set ready");
  332.         if(stat & 0x0010)
  333.             puts("clear to send");
  334.         if(stat & 0x0008)
  335.             puts("delta line signal detect");
  336.         if(stat & 0x0004)
  337.             puts("trailing edge ring detect");
  338.         if(stat & 0x0002)
  339.             puts("data set ready");
  340.         if(stat & 0x0001)
  341.             puts("delta clear to send);
  342.  
  343. -------------------------------------------------------------------------
  344.  
  345. pos(row,col)
  346.  
  347. This fundtion returns the current row and column of the cursor.  The
  348. arguments are pointers and have to be passed to the function as 
  349. addresses.  The function is called as follows.
  350.  
  351.  
  352.     main()
  353.     {
  354.         int row,col;
  355.         pos(&row,&col);
  356.         printf("The cursor is at row %d and col %d\n",row,col);
  357.     }
  358.  
  359. or can be called as
  360.  
  361.         int *row,*col;
  362.         pos(row,col);
  363.         printf("cursor at row %d, and col %d\n",*row,*col);
  364.  
  365.  
  366.  
  367. -------------------------------------------------------------------------
  368.  
  369. prtscn()
  370.  
  371. This function prints the screen to the line printer.  I use it a lot
  372. when users get into serious trouble in the program and I have a hard
  373. copy of what they were doing when the error occurred.  It is called
  374. as follows.
  375.  
  376.  
  377.     main()
  378.     {
  379.         prtscn();
  380.  
  381.     }
  382.  
  383.  
  384.  
  385. -------------------------------------------------------------------------
  386.  
  387.  
  388. reboot()
  389.  
  390. This function cause the system to reboot as if pressing Ctrl-Alt-DEL keys
  391. do.  I sometimes use this in a program when a user has really gotten into
  392. trouble and the only thing to do is reboot the system.  It is called as
  393. follows
  394.  
  395.  
  396.     main()
  397.     {
  398.         reboot();
  399.     }
  400.  
  401.  
  402. -------------------------------------------------------------------------
  403.  
  404. setport(port,rate,parity,bits,stop)
  405.  
  406. This function sets a serial or communications port to the specified baud
  407. rate, parity, word length, and stop bits.  It is called as follows.
  408.  
  409.  
  410.     main()
  411.     {
  412.         setport(1,1200,'N',8,1);
  413.     }
  414.  
  415.  
  416. The baud rate parameter can range from 110 to 9600.
  417. Parity can be 'E' for even parity, 'O' for odd, or 'N' for no parity.
  418. the bits or wordlength can be 7 or 8 data bits.
  419.  
  420. stop bits can be 1 or 2;
  421.  
  422.  
  423. -------------------------------------------------------------------------
  424.  
  425.  
  426. shift()
  427.  
  428. This function returns the shift status of the keyboard.  It can be
  429. called and tested as follows.
  430.  
  431.     main()
  432.     {
  433.         x=shift();
  434.         if(x & 0x80)
  435.             puts("Insert key locked on");
  436.         if(x & 0x40)
  437.             puts("Caps key locked on");
  438.         if(x and 0x20)
  439.             puts("Num Lock Key locked on");
  440.         if(x and 0x10)
  441.             puts("Scroll Lock key locked on");
  442.         if(x & 0x08)
  443.             puts("Alt Shift key depressed");
  444.         if(x & 0x04)
  445.             puts"Ctrl Shift Key depressed");
  446.         if(x & 0x02)
  447.             puts("Left shif key depressed");
  448.         if(x & 0x01)
  449.             puts("Right shift key depressed");
  450.  
  451.  
  452.  
  453. -------------------------------------------------------------------------
  454.  
  455.  
  456. END OF DOCUMENTATION
  457.  
  458.  
  459.  
  460.  
  461.             
  462.  
  463.  
  464.  
  465.  
  466.  
  467.